<template>
  <div class="containerSta">
    <div class="containerSta-operate">
      <p :class="{ active: clickActive == 1 }" @click="AnalysisInfo(1)">
        数据分析
      </p>
      <p :class="{ active: clickActive == 2 }" @click="gotoUserInfo(2)">
        用户管理
      </p>
      <p :class="{ active: clickActive == 3 }" @click="gotoRoomInfo(3)">
        房屋管理
      </p>
      <p :class="{ active: clickActive == 4 }" @click="gotoStaticsInfo(4)">
        数据统计
      </p>
    </div>
    <div class="containerSta-content">
      <router-view />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref } from "@vue/runtime-core";
import { watch } from "vue";
import { useRouter } from "vue-router";

export default defineComponent({
  components: {},
  setup() {
    const router = useRouter();
    const clickActive = ref(1);
    const AnalysisInfo = (val: number) => {
      clickActive.value = val;
      router.push("/analysis");
    };
    const gotoUserInfo = (val: number) => {
      clickActive.value = val;
      router.push("/userInfo");
    };
    const gotoRoomInfo = (val: number) => {
      clickActive.value = val;
      router.push("/roomInfo");
    };
    const gotoStaticsInfo = (val: number) => {
      clickActive.value = val;
      router.push("/statisticsInfo");
    };
    onMounted(() => {
      const pathValue = router.currentRoute.value.path;
      if (pathValue == "/analysis") clickActive.value = 1;
      if (pathValue == "/userInfo") clickActive.value = 2;
      if (pathValue == "/roomInfo") clickActive.value = 3;
      if (pathValue == "/statisticsInfo") clickActive.value = 4;
    });
    return {
      AnalysisInfo,
      gotoUserInfo,
      gotoRoomInfo,
      gotoStaticsInfo,
      clickActive,
    };
  },
});
</script>

<style lang="scss" scoped>
.containerSta {
  margin: 10px 0 0 0;
  display: flex;
  justify-content: flex-start;
  // height: 100vh;
  &-operate {
    min-width: 10%;
    max-width: 10%;
    height: 100%;
    background: #f5f7fa;
    p {
      width: 100%;
      height: 40px;
      line-height: 40px;
      text-align: center;
      font-size: 18px;
      letter-spacing: 2px;
      font-weight: bold;
      cursor: pointer;
    }
    p:hover {
      color: #1296db;
    }
    .active {
      color: #1296db;
    }
  }
  &-content {
    width: 89%;
    margin: 0 10px 10px;
  }
}
</style>